/**
 * Copyright 2025 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "test_view.h"
#include "ir/tensor_new.h"
#include "view/view_strides_calc.h"
#include "mindspore/core/include/ir/tensor_storage_info.h"

namespace mindspore {
namespace ops {
class TestViewView : public TestView {
 public:
  TestViewView() {}
};

/// Feature: View strides calculator
/// Description: Test view View strides calculator is right
/// Expectation: success
TEST_F(TestViewView, ViewFunction) {
  // split_size <= 0
  std::vector<int64_t> tensor_data{1, 2, 3, 4};
  auto input_tensor = tensor::from_vector(tensor_data, kInt64);
  input_tensor->set_shape({2, 2});
  auto input_storage_info =
    std::make_shared<TensorStorageInfo>(std::vector<int64_t>{2, 2}, std::vector<int64_t>{1, 2},
                                        std::vector<int64_t>{2, 2}, std::vector<int64_t>{2, 1}, false);
  const auto &input_device_address = input_tensor->device_address();
  ASSERT_TRUE(input_device_address != nullptr);
  input_device_address->set_tensor_storage_info(input_storage_info);
  ASSERT_THROW(ViewBasicTypeCalc(input_tensor, {4}), std::exception);
}
}  // namespace ops
}  // namespace mindspore